/**
 * Created by Administrator on 2017/3/25.
 */
//   不可控
/*var FormComponent  = React.createClass({
    handleSubmit:function (e) {
        e.preventDefault();//阻止表单的默认行为
        var text= this.refs.input_name.value;//old react.findDomNode
        alert(text);
    },
    render:function () {
        return <form onSubmit={this.handleSubmit}>
            <input type="text" ref="input_name" defaultValue="hello ...."/>
            <button type="submit" >提交</button>
        </form>
    }

});*/


var FormComponent = React.createClass({
    getInitialState:function () {
        return {text:"hello"}
    },
    handleSubmit:function (e) {
        e.preventDefault();
        alert(this.state.text);
    },
    handleChange:function (e) {
        this.setState({text:e.target.value});
    },
    render:function () {
        return <form  onSubmit={this.handleSubmit}>
            <input type="text" default={this.state.text} onChange={this.handleChange} ></input>
            <button type="submit">commit</button>
        </form>
    }

});
ReactDOM.render(<FormComponent></FormComponent>, document.body);